package cn.pxs.service;

import cn.pxs.entity.User;
import cn.pxs.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;


@Primary
@Service//UserDetailService的实现类
public class UserDetailServiceImpl implements UserDetailsService {
    @Autowired
    UserMapper userMapper;

    @Override
    //获取用户信息
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        User u = userMapper.findUserByAccount(s);//s为网页传输的账号
        return u;
    }
}
